<template>
  <button @click="handleAxios">请求服务器</button>
</template>

<script>
import { reactive, toRefs } from 'vue'
import axios from 'axios'
export default {
  setup () {
    const state = reactive({
      count: 0
    })
    const handleAxios = () => {
    //  axios.get('/user?ID=12345')
    //  .then(function (response) {
    //    console.log(response)
    //  })
    //  .catch(function (error) {
    //    console.log(error)
    //   })
    axios.request({
      method: 'post',
      url: 'http://localhost/',
      baseURL: 'http://localhost/',
      data: {
        firstName: 'Fred',
        lastName: 'Flintstone'
      }
    })
    .then(function (response) {
      console.log(response);
    })
    .catch(function (error) {
      console.log(error);
    })

  }

    return {
      ...toRefs(state),
      handleAxios
    }
  }
}
</script>

<style  scoped>

</style>